/*
 * @desc:
 * @LastEditTime: 2024-03-20 18:04:05
 * @params:
 * @return::
 */
const mongoose = require("mongoose");
const baseModle = require("./base-model");
const Schema = mongoose.Schema;

const ArticleSchema = new mongoose.Schema({
  ...baseModle,
  title: {
    type: String,
    required: true,
  },
  content: {
    type: String,
    required: true,
  },
  authorName: {
    type: String,
    default: "天才教授🍤",
  },
  image: {
    type: [String],
    required: true,
  },
  authorAvatarUrl: {
    type: String,
    required: true,
  },
  tagList: {
    type: [String],
    default: null,
  },
  favourite: {
    type: Boolean,
    default: false,
  },
  favouritesCount: {
    type: Number,
    default: 0,
  },
  author: {
    type: Schema.Types.ObjectId,
    ref: "User",
    // required: true,
  },
  comments: {
    type: [String],
    default: [],
  },
  openId: {
    type: String,
    default: "test",
  },
  // 在 ArticleSchema 中添加
  favouriteUsers: [
    {
      type: Schema.Types.ObjectId,
      ref: "User",
    },
  ],
});

module.exports = ArticleSchema;
